<?php

include 'islogin.php';

include '../config.php';



if(isset($_POST['flag']))

{

	if($_POST['flag']=="add")

	{

		$sql = "insert into en_pro_type(name,flag) values('".$_POST['name']."',1)";

		mysql_query($sql);

	}
}

if($_GET['flag'] == 'delete')
{
	$sql = "delete from en_pro_type where id = {$_GET['id']}";
    mysql_query($sql);
    $sql_2 = "delete from en_product where find_in_set('{$_GET['id']}', type_id)";
    mysql_query($sql_2);
}

?>

<script src="../js/jquery-1.7.1.js"></script>

<link href="images/skin.css" rel="stylesheet" type="text/css" />

<link href="css/right.css" rel="stylesheet" type="text/css"/>

<script>

function mouseoverTD(obj)

{

	   $(obj).css("background","#aaa");

}

function mouseoutTD(obj)

{

	  $(obj).css("background","");

}

</script>

<div style="border:0px solid red;"> 



    	<div id="top"><div>产品类型</div></div>

    	

	    <div id="middle">

	    	<!-- 类型列表 -->

	      <div class="layout">

		       <div class="title">类型列表</div>

		       <div class="content">

		       

		       	 <table  cellspacing="0" cellpadding="0">  

			   				<tr >

				   		   		<td class="title_some_td" style="width:100px; text-align:center;">序号</td>

				   		   		<td class="title_some_td" style="width:100px; text-align:center;">类型名称</td>

				   		   		<td class="title_some_td" style="width:100px; text-align:center;">操作</td>

				   		   </tr>

				   		   <?php 

				   		   		$sql = "select id,name from en_pro_type where flag =1";

				   		   		$result = mysql_query($sql);

				   		   		while($row = mysql_fetch_array($result))

				   		   		{

				   		   	?>

				   		   		<tr style='cursor:pointer;'  onmouseover='mouseoverTD(this)' onmouseout='mouseoutTD(this)'>

				   		   			<td class="context_td" style="width:100px; text-align:center;"><?php echo $row['id'];?></td>

				   		   			<td class="context_td" style="width:100px; text-align:center;"><?php echo $row['name'];?></td>

				   		   			<td class="context_td" style="width:100px; text-align:center;">

				   		   			<a style='text-decoration:underline;' href='pro_typeUpdate.php?flag=update&id=<?php echo $row['id']?>'>修改</a>
				   		   			<a style='text-decoration:underline;' onclick="return confirm('确定要删除该分类吗?')" href='pro_type.php?flag=delete&id=<?php echo $row['id']?>'>删除</a>

				   		   			</td>

				   		   		</tr>

				   		   	

				   		   	<?php

				   		   		}

				   		   ?>

				  </table> 		   

		       </div>

		  </div>

		  

		  <div class="layout">

		  	<div class="title">增加类型</div>

		       <div class="content">

		       <form action="pro_type.php" method="post">

		         <input type="hidden" name="flag" value="add" />

		          <table  cellspacing="0" cellpadding="0">  

		          	<tr>

		          		<td class="title_some_td" style="width:100px;">类型名称:</td>

		          		<td><input name="name"  /></td>

		          	</tr>

		          	<tr>

		          		<td></td>

		          		<td><input type="submit" value="增加" /></td>

		          	</tr>

		          </table>

		      </form>    

		       </div>

		  </div>

		</div>	

		

	<div id="bottom"></div>		

</div>			  

		       